package com.meixiang.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;

import com.meixiang.R;

/**
 * 正在加载Dialog(商城中需要使用)
 *
 * @author LZRUI
 */
public class LoadingDialog extends Dialog {

    private AnimationDrawable drawable;

    public LoadingDialog(Context context) {
        this(context, R.style.loadingDialogStyle);
    }

    public LoadingDialog(Context context, int themeResId) {
        super(context, themeResId);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_loading);
        ImageView ivLoad = (ImageView) findViewById(R.id.iv_load);
        drawable = (AnimationDrawable) ivLoad.getDrawable();
        drawable.start();
    }

    @Override
    public void dismiss() {
        if (drawable!= null) {
            drawable.stop();
        }
        super.dismiss();
    }
}
